//数据类连接层
const Sequelize = require('sequelize')
const path = require('path')
const {
    mysqlOptions
} = require(path.join(__dirname, 'config'))

const sequelize = new Sequelize('test', 'root', '123456', {
    host: mysqlOptions.host,
    dialect: mysqlOptions.dialect, //连接数据类类型
    timezone: mysqlOptions.timezone, //时区
    //数据库连接池
    pool: {
        max: mysqlOptions.pool.max,
        min: mysqlOptions.pool.min,
        acquire: mysqlOptions.pool.acquire, //连接超时
        idle: mysqlOptions.pool.idle //闲置时间
    },
    define: {
        timestamps: mysqlOptions.define.timestamps
    }
})

let db = {}
db.sequelize = sequelize;
db.Sequelize = Sequelize;

module.exports = db;